import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { ClientDto } from 'src/app/models/sys/client.dto';
import { ApiService } from 'src/app/services/api.service';

@Component({
  selector: 'app-client-detail',
  templateUrl: './client-detail.component.html',
  styleUrl: './client-detail.component.less'
})
export class ClientDetailComponent implements  AfterViewInit {
  @Input() clientSubject = new BehaviorSubject<ClientDto>(new ClientDto());
  @Output() detailEvent = new EventEmitter<boolean>();

  client?: ClientDto;

  constructor(private _api: ApiService) {

  }
  ngAfterViewInit(): void {
    setTimeout(() => {
      this.clientSubject.subscribe((value) => {
        this.client = value;
      });
    });
  }

  onClose(event: UIEvent) {
    event.preventDefault();

    this.detailEvent.emit(true);
  }
}
